package io.renren.modules.learn.dao;

import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

@Mapper
public interface StudentProgressDao {
    /**
     * 根据用户ID和知识类型查询用户学习进度位图
     * @param userId
     * @param knowledgeType
     * @return
     */
    @Select("SELECT progress_bitmap FROM `student_progress` " +
                "WHERE student_id=#{userId} AND knowledge_type = #{knowledgeType};")
    String queryBitmapByUserIdAndKnowledgeType(Long userId, int knowledgeType);

    /**
     * 更新位图根据用户ID和知识类型用户学习进度位图
     * @param userId
     * @param knowledgeType
     * @param bitmap
     */
    @Update("UPDATE `student_progress` SET progress_bitmap = #{bitmap} WHERE student_id=#{userId} AND knowledge_type = #{knowledgeType}")
    void setBitmapByUserIdAndKnowledgeType(@Param("userId") Long userId, @Param("knowledgeType") int knowledgeType, @Param("bitmap") String bitmap);
}
